<%-- 
    Document   : AdminDashboard
    Created on : Feb 22, 2014, 10:39:07 AM
    Author     : Mukesh
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
    try {
        if (session.getAttribute("uid") != null) {
            if (session.getAttribute("Access_Permission").toString().equals("1")) {
%>
<html>
    <head>
        <title>Ramgovind Automated System</title>

        <link rel="stylesheet" href="/RIT/css/bootstrap.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap-responsive.css">
        <link rel="stylesheet" href="/RIT/css/jquery.fancybox.css">
        <link rel="stylesheet" href="/RIT/css/style.css">
        <link rel="stylesheet" href="/RIT/css/iconfont.css">
        <script type="text/javascript">
            function checkUncheck(id)
            {
                var val=id.split("/");
                if(val[1]=="Head")
                {
                    if(document.getElementById(id).checked)
                    {
                        for(var j=1;j<=val[0];j++)
                        {
                            document.getElementById(j+"/Child/"+val[2]+j).checked=true;
                            document.getElementById(j+"/Child/"+val[2]+j).disabled=true;     
                        }
                    }
                    else
                    {
                        for(var j=1;j<=val[0];j++)
                        {
                            document.getElementById(j+"/Child/"+val[2]+j).checked=false;
                            document.getElementById(j+"/Child/"+val[2]+j).disabled=false;    
                        } 
                    } 
                }
                else
                {
                    if(val[1]!="Child")
                    {
                        document.getElementById(id).checked=false; 
                    }
                }
            }
            function loadAcess(id)
            {
                document.getElementById('ILoader').setAttribute("style", "visibility: visible;width: 250px;height: 250px;position: absolute;top: 50%;left:50%;margin-top: -80px;margin-left: -40px;background:url(/RIT/img/loader.gif) no-repeat;z-index: 667999;background-size:200px 200px;");
                var xmlhttp; 
                if (window.XMLHttpRequest)
                {
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange=function()
                {
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    { 
            
                        document.getElementById('acc').innerHTML=xmlhttp.responseText;
                        document.getElementById('ILoader').removeAttribute('style');
                    }
                }
                xmlhttp.open("POST","/RIT/UserAcessPermission?id="+id,false);
                xmlhttp.send();
            }
            function disableSubmit()
            {
                if(document.getElementById('uid').value>0)
                {
                    document.getElementById('sub').disabled=false;
                }
                else
                {
                    document.getElementById('sub').disabled=true;
                }
            }
            function disableForm()
            {
                if(document.getElementById('check').checked)
                {
                    document.getElementById('acc').style.display='none';
                }
                else
                {
                    document.getElementById('acc').style.display='block';  
                }
            }
        </script>
    </head>
    <body onload="loadAcess('<%=request.getParameter("id")%>'),disableSubmit()">
        <div id="ILoader"></div>
        <%@include file="/topheader.html" %>
        <%@include file="/servicesheader.html" %>
        <div class="main">
            <div class="container-fluid">

                <%@include file="/Services/HR/hrsidenav.jsp" %>
                <div class="content">

                    <div class="row-fluid">
                        <div class="span12">
                            <div class="box">
                                <div class="box-head">
                                    <h3>User Access Permission</h3>
                                </div>
                                <div class="box-content">
                                    <form action="/RIT/UserAcessPermissionServlet" class="form-horizontal">
                                        <div class='control-group'>
                                            <label for='select' class='control-label'>User Name</label>
                                            <div class='controls'>
                                                <input type='hidden' value='<%=request.getParameter("id")%>' name='uid' id='uid'>
                                                <input type='text' value='<%=request.getParameter("name")%>' name='ename' id='ename' readonly>
                                            </div></div>
                                        <div class="controls">
                                            <label class="checkbox"><input type="checkbox" name="check" id="check" onclick="disableForm()" value="Withdraw">Do you want to withdraw All Access Permission?</label>
                                        </div>
                                        <div id="acc"></div>
                                        <div class='form-group'>
                                            <button class='btn btn-primary controls' type='submit' id='sub'>Submit</button>
                                            <input type='reset' class='btn btn-danger' value='reset'>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>	
            </div>
        </div>	
        <script src="/RIT/js/jquery.js"></script>
        <script src="/RIT/js/less.js"></script>
        <script src="/RIT/js/bootstrap.min.js"></script>
        <script src="/RIT/js/jquery.peity.js"></script>
        <script src="/RIT/js/jquery.fancybox.js"></script>
        <script src="/RIT/js/jquery.flot.js"></script>
        <script src="/RIT/js/jquery.color.js"></script>
        <script src="/RIT/js/jquery.flot.resize.js"></script>
        <script src="/RIT/js/jquery.cookie.js"></script>
        <script src="/RIT/js/jquery.cookie.js"></script>
        <script src="/RIT/js/custom.js"></script><script src="js/demo.js"></script>
        <script src="/RIT/js/iconfont.js"></script>
    </body>
</html>
<%} else {
%>
<script type="text/javascript">
    alert("You Are Not Authorised");
    window.history.back();
</script>
<%             }
        } else {
            request.setAttribute("msg", "You Are Not Authorised! Please Contact to System Administrator!");
            request.setAttribute("value", "0");
            getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
        }
    } catch (Exception e) {
        request.setAttribute("msg", "Please Contact to System Administrator!");
        request.setAttribute("value", "0");
        getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
    }
%>

